package com.woniuxy.credit_loans.util;

import org.springframework.stereotype.Component;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ：halisir
 * @date ：Created in 2022/12/13 20:02
 * @description：
 * @modified By：
 * @version: $
 */
@Component
public class TimeUtilLi {
    public static Date StringToDate(String arg) throws ParseException {
//        arg = "2012-12-12 12:11:30";
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date parse = dateFormat.parse(arg);
        return parse;
    }
    public static String DateToString(Date date){
        int year = date.getYear()+1900;
        int month = date.getMonth()+1;
        int day = date.getDate();
        int hours = date.getHours();
        int minutes = date.getMinutes();
        int seconds = date.getSeconds();
        String s = year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;

        return s;
    }
}
